Programming Techniques


1. Source File

yos_main.c Main
oam_proc.c OAM process
memu.c Menu
menu_dat.c Menu data
yos_game.c Game main
yos_game_dat.c Game data
yos_game_mov.c Motion process routines for the various characters
yos_game_pr.c Display process routines for the various characters
yos_anm.c Animation data
yos_game_sub.c Miscellaneous process routines
bg_proc.c Game's BG process, display routines

2. Game Flow


3. Program Explanations

3.1. Using make

In the sample_yoshi/ directory, enter:

   make data
   make

Running "make data" creates the data archives (bmp/islebmp/libislebmp.a, bmp/menubmp/libmenubmp.a, bmp/yosbmp/libyosbmp.a, bmp/yosbgbmp/libyosbgbmp.a), which are linked to the program when "make" is run.

3.2. Program Flow

Main() in yos_main.c is the game's main loop. From inside this main loop, either

proc_0()
Menu (island rotation)

or

yos_game()
Yoshi game

is called in every frame, according to the value of gMain.proc_num.

3.3. Processing During V Blank

The V blank interrupt routine is VBlankIntr() in yos_main.c. (*gMain.pVBlankFunc)() is called after exiting VBlankIntr(). A child process you want to perform during V blank can be called by inserting a pointer in the (*gMain.pVBlankFunc).

The interrupt routine takes a long time, so this is done in order to avoid influence from another interrupt.

3.4. Processing During H Blank

H blank interrupts are used for the Menu's ocean and sky. Inside the child process, the H blank process directly changes table values for addresses called from the interrupt routine.

3.5. Work Memory

Specifying with the "lnkscript" file overlays the work areas of child processes for

-- The menu
-- The game itself

Overlays are only done for the (COMMON) area in Yoshi's link script, so local variables are not used inside the file.

* Variables that can been seen from outside the file are (COMMON), while those that cannot be seen are (bss).

3.6. CPU Processing Time Measurements During the Yoshi Game

When SPEED-CHK is defined in yos_game.h, an egg will be displayed on the screen when the START button is pushed. The center X coordinate of this egg (the origin is at the left side of the screen) indicates the line number for the raster position at the time the game process ends. The maximum is the 100th position. You can change the measurement position by going to

  p1_line_count = ...

in game_main() and changing the line insert position forward and backward.

3.7. BG for the Menu (Island)

Uses BG mode 2. One is for ocean & sky, and the other is for the island.

Changing the scaling parameter during H blank changes the perspective. Changing the scaling parameter also scrolls the sky.

3.8. BG During the Game

Uses BG mode 1

Distant View 16 colors Screen size 256 x 256
Mid-Distance View 256 colors Screen size 256 x 256
Near View Scaled (256 colors) Screen size 512 x 512

3.9. BG for the Castle

Uses BG mode 3 (65,536 colors).

3.10. OBJs in Game

All OBJs are 256 colors. Also, all enlarged OBJs are always in double-size character mode.

3.11. Animation for Yoshi, etc.

This is performed by overwriting image data in VRAM. Data is DMA transferred inside functions called after V blanks.

For some things like dash smoke, the complete pattern is held in VRAM.

3.12. Display Priority of OBJs in Game

Ten OAM lists are made, and things for display are placed inside the OAM lists. After all things have been placed inside the lists, OAM data is created in order of priority from the lists and DMA transferred during V blanks.

The lists are cleared at the start of every frame, so something that is not put in the list every time will not be displayed.

3.13. Linking the Image Data

BG for the game is compiled after being converted to C source by bmp2agb.exe. Other image data is first converted to binary by bmp2bin or bmp2map, and then turned into an object file (.o) by objcopy.

The image data takes up considerable volume, so it is archived with "ar" and linked as a library when the program is compiled.

AGB-06-0033-001A (2/26/01)
© 2001 Nintendo of America Inc.